<%@ page language="java" pageEncoding="UTF-8"%><%@ include
	file="/WEB-INF/commons/taglibs.jsp"%>
<script type="text/javascript">
function showMsg($item, msgType, msg, timeout){
	var classType='ui-state-highlight';
	if(msgType=='error'){
		classType='ui-state-error';
	}
	$item.addClass(classType);
	$item.html("<span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span>"+msg);
	setTimeout(function(){$item.html('').removeClass(classType);},timeout);
}
function register(){
	$.ajax({
		url: '/user/ajax/register',
		data: 'id='+$('#id').val()+'&password='+$('#password').val(),
		type: 'POST',
		timeout: 15000,
		error: function(){showMsg($('#message'),'error','用户注册失败!',3000);},
		success: function(response){
			if(response.search('ERROR')!=-1){
				showMsg($('#message'),'error','用户注册失败!',3000);
			}else{
				showMsg($('#message'),'info','用户注册成功!',5000);
				setTimeout(function(){window.location.href='/index';},4000);
			}
		}
	});
}
$(function(){
$('#btnRegister').button().click(function(){$(this).attr('disabled',true);register();$(this).attr('disabled',false);});
});
</script>
<div id="register">
<form name="userForm" action="/register" method="POST"><label
	for="id">Email: <br />
<input type="text" id="id" name="id" /></label><br />
<label for="password">Password: <br />
<input type="password" id="password" name="password" /></label></form>
<div class="btnContainer">
<button id="btnRegister">注册</button>
</div>
</div>